home *** CD-ROM | disk | FTP | other *** search
- /* PPaint Amiga Rexx script - Copyright © 1995 Cloanto Italia srl */
-
- /*
- $VER: GifToPng.pprx 1.0
-
- This script asks the user to specify a directory, scans the directory
- and its subdirectories and converts all GIF files it finds into PNG.
-
- Non-GIF files are not affected. Icon images are preserved. Icon format
- information is updated (Tool Types: FILETYPE=PNG). File name suffixes are
- changed (i.e. the files are renamed) as follows:
-
- .gif -> .png
- .GIF -> .PNG
- .Gif -> .Png, ecc.
-
- others -> unchanged
-
- Personal Paint identifies the file type by its contents (not by the file
- name suffix). If the script runs during Workbench use, the Workbench Update
- menu item must be selected to visually update the contents of any windows
- containing files being renamed by this script.
-
- This script requires Personal Paint version 6.3 (PPaint Rexx version 2)
- or higher, personal_png_io.library (enclosed with PPaint), and
- personal_gif_io.library (available via free electronic distribution).
-
-
- Possible changes that could be applied to this file:
-
- Convert all images to PNG (not just GIFs). To do this, change the line
- selecting GIFs to IF UPPER(RESULT) ~= 'PNG' THEN DO. However, be careful
- if you have IFF animations, as they would be processed as ILBM images
- (IFF animations begin with an ILBM image).
-
- Activate PNG Adam 7 progressive display in files being written. This
- degrades compression but the resulting images appear more nicely when
- displayed by progressive viewers. Set PROGDSP=1.
-
- Convert any file to uncompressed IFF-ILBM. This may be good for files to
- be stored on an Amiga CD-ROM, where loading speed could be more important
- than compression. Remove the instructions selecting only GIFs and replace
- the PNG FORMAT option with FORMAT ILBM OPTIONS "COMPR=0" "SCRFMT=0".
-
-
- PNG was designed as a replacement and extension to GIF and LZW-based TIFF,
- after Unisys Corporation began demanding royalties on GIF/LZW code. As
- the PNG specification was released in May 1995, it gained general
- recognition as the best lossless standard for storing digital images.
-
- Cloanto, the first software house to publish a paint program supporting the
- PNG file format, is also making available a PNG developer's kit for the
- Amiga. This includes instructions for using personal_png_io.library, and is
- a commercial product. A PNG DataType is available at no cost for free
- electronic distribution.
-
- An article on the GIF/LZW issue can be requested by sending E-mail to
-
- <gltext1@cloanto.it>
-
- For more information, or suggestions, please address E-mail to
-
- <info@cloanto.it>
-
- */
-
-
- MYPORT = 'PPAINT'
-
- IF ~SHOW('P', MYPORT) THEN DO
- IF EXISTS('PPaint:PPaint') THEN DO
- ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
- DO 30 WHILE ~SHOW('P',MYPORT)
- ADDRESS COMMAND 'Wait >NIL: 1 SEC'
- END
- END
- ELSE DO
- SAY "Personal Paint could not be loaded."
- EXIT 10
- END
- END
-
- IF ~SHOW('P', MYPORT) THEN DO
- SAY 'Personal Paint Rexx port could not be opened.'
- EXIT 10
- END
-
- ADDRESS VALUE MYPORT
- OPTIONS RESULTS
- OPTIONS FAILAT 10000
-
- Version 'REXX'
- IF RESULT < 2 THEN DO
- errmess = 'This script requires a newer_version of Personal Paint.'
- SAY errmess
- RequestNotify 'PROMPT="'errmess'"'
- EXIT 10
- END
-
- LockGUI
- FreeBrush
- IF RC = 0 THEN RequestPath '"GifToPng target directory"'
- IF RC = 0 THEN DO
- tmpfname = 'T:pprx_temp.'PRAGMA('ID')
- ADDRESS COMMAND 'List >'tmpfname' 'RESULT' NOHEAD PAT=~(#?.info) LFORMAT="*"%s%s*"" ALL FILES'
- IF OPEN('listfile', tmpfname, R) THEN DO
- Get SETTING ICONS
- iconmode = RESULT
- errcode = 0
- Set '"ICONS=3"'
- DO FOREVER
- curfname = READLN('listfile')
- IF EOF('listfile') THEN BREAK
- GetFileFormat curfname
- IF RC = 0 THEN DO
- IF UPPER(RESULT) = 'GIF' THEN DO
- SAY 'Processing 'curfname
- LoadBrush curfname FORCE
- IF RC = 0 THEN DO
- IF UPPER(RIGHT(curfname, 5)) = '.GIF"' THEN DO
- len = LENGTH(curfname)
- newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-3, 1)) + 9), curfname, len-3)
- newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-2, 1)) + 5), newfname, len-2)
- newfname = OVERLAY(D2C(C2D(SUBSTR(curfname, len-1, 1)) + 1), newfname, len-1)
- IF EXISTS(SUBSTR(newfname,2,len-2)) = 0 THEN DO
- ADDRESS COMMAND 'Rename >NIL: 'curfname' 'newfname
- curiconfname = INSERT('.info', curfname, len-1)
- newiconfname = INSERT('.info', newfname, len-1)
- curfname = newfname
- IF EXISTS(SUBSTR(curiconfname,2,len+3)) THEN DO
- IF EXISTS(SUBSTR(newiconfname,2,len+3)) THEN
- ADDRESS COMMAND 'Delete >NIL: 'curiconfname
- ELSE
- ADDRESS COMMAND 'Rename >NIL: 'curiconfname' 'newiconfname
- END
- END
- END
- SaveBrush 'FORCE FILE 'curfname' FORMAT PNG OPTIONS "PROGDSP=0" "COMPR=6" "AUTO=1"'
- IF RC > 0 THEN DO
- errcode = RC
- IF RC = 5 THEN
- errmess = 'User abort during save.'
- ELSE
- errmess = 'Error 'RC' during save.'
- END
- FreeBrush FORCE
- END
- ELSE DO
- errcode = RC
- IF RC = 5 THEN
- errmess = 'User abort during load.'
- ELSE
- errmess = 'Error 'RC' during load.'
- END
- END
- END
- IF errcode > 0 THEN BREAK
- END
- IF errcode > 0 THEN DO
- SAY errmess
- RequestNotify 'PROMPT="'errmess'"'
- END
- Set '"ICONS='iconmode'"'
- CALL CLOSE('listfile')
- END
- ADDRESS COMMAND 'Delete >NIL: 'tmpfname
- END
- UnlockGUI
-